<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .true {
            color: greenyellow;
        }

        .false {
            color: red;
        }
    </style>
</head>

<body>
    <input type="text" class="content">
    <span></span>

    <script>
        const content = document.querySelector('.content')
        const span = document.querySelector('span')
        content.addEventListener('blur', function () {
            if (/^[a-zA-Z0-9]{6,10}$/.test(content.value)) {
                span.classList.remove('false')
                span.innerHTML = '输入正确'
                span.classList.add('true')
            }
            else {
                span.classList.remove('true')
                span.classList.add('false')
                span.innerHTML = '您的输入有误'


            }



        })
    </script>
</body>

</html>